home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 12 / BBS in a box XII-1.iso / Files / DA / J-Z / ResExpress 1.0.1.sit / ResExpress 1.0.1 ƒ / ResX DevKit / Think C / ResX_Shell.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-01-17  |  3.7 KB  |  117 lines  |  [TEXT/KAHL]

  1. #include "ResX.h"
  2. #include <String.h>
  3.  
  4. pascal void main ( Handle ResHandle )
  5. {
  6.     GlobalsPtr        Globals = (GlobalsPtr) ( (WindowPeek) FrontWindow () ) -> refCon;
  7.     SignedByte        HState;
  8.     short            fileID;
  9.     Boolean            MF;
  10.     char            *fName;
  11.     
  12.     /***********************************/
  13.     /**   VARIABLES FOR EXAMPLE CODE  **/
  14.     /***********************************/
  15.     GrafPtr            hostPort;
  16.     Rect            r;
  17.     WindowPtr        w;
  18.     short            fontNum, ypos = 0;
  19.     Str255            utility_string;
  20.     
  21.     /********************************************/
  22.     /*    Sample of accessing the global data:    */
  23.     
  24.     fileID = (*Globals).LfileID;            /*    Get the file id left file            */
  25.     fName = (char *) (*Globals).LeftFName;    /*    Get the file name of the left file    */
  26.     MF =(*Globals).MFActive;                /*    Is MultiFinder running?                */
  27.  
  28.  
  29.     HState = HGetState ( ResHandle );        /*    This is mandatory!                    */
  30.  
  31.  
  32.     LoadResource(ResHandle);                /*    This is necessary if you            */
  33.                                             /*    plan to use it.                        */
  34.                                             /*    ResX doesn't load it.                */
  35.     
  36.     
  37.     /**********************
  38.         
  39.         your main code here...
  40.     
  41.     **********************/
  42.  
  43. /**************************************************************/
  44. /***** EXAMPLE CODE - DISPLAY STUFF WE GOT FROM GLOBALPTR *****/
  45. /**************************************************************/
  46.     GetPort ( & hostPort );
  47.     r = hostPort->portRect;
  48.     LocalToGlobal ( & topLeft ( r ) );
  49.     LocalToGlobal ( & botRight ( r ) );
  50.     InsetRect ( & r, 32, 32 );
  51.     
  52.     w = NewWindow ( (Ptr) 0L, & r, "\pShow Info", TRUE, noGrowDocProc, (WindowPtr) -1L, FALSE, 0 );
  53.     if ( w != 0L )
  54.         {
  55.             SetPort ( w );
  56.             GetFNum ( "\pGeneva", & fontNum );
  57.             TextFont ( fontNum );
  58.             TextSize ( 9 );
  59.  
  60. /*******************  FILE ID FROM GLOBALPTR  ******************/            
  61.             strcpy ( (char *) utility_string, "\pFile ID from GlobalPtr: " );
  62.             MoveTo ( 196 - StringWidth ( utility_string ), ypos += 12 );
  63.             DrawString ( utility_string );
  64.             
  65.             MoveTo ( 200, ypos );
  66.             NumToString ( (long) fileID, utility_string );
  67.             DrawString ( utility_string );
  68.  
  69. /*******************  FILE ID FROM RESHANDLE  ******************/            
  70.             strcpy ( (char *) utility_string, "\pFile ID from HomeResFile ( ResHandle ): " );
  71.             MoveTo ( 196 - StringWidth ( utility_string ), ypos += 12 );
  72.             DrawString ( utility_string );
  73.             
  74.             NumToString ( (long) HomeResFile ( ResHandle ), utility_string );
  75.             MoveTo ( 200, ypos );
  76.             DrawString ( utility_string );
  77.             
  78.             
  79. /*******************  FILE NAME FROM GLOBALPTR  ******************/            
  80.             strcpy ( (char *) utility_string, "\pFile Name from GlobalPtr: " );
  81.             MoveTo ( 196 - StringWidth ( utility_string ), ypos += 12 );
  82.             DrawString ( utility_string );
  83.             
  84.             MoveTo ( 200, ypos );
  85.             DrawString ( fName );
  86.  
  87. /*******************  IS MULTIFINDER ACTIVE?  ******************/
  88.             strcpy ( (char *) utility_string, "\pMF from GlobalPtr: " );
  89.             MoveTo ( 196 - StringWidth ( utility_string ), ypos += 12 );
  90.             DrawString ( utility_string );
  91.             
  92.             MoveTo ( 200, ypos );
  93.             DrawString ( (MF)?("\pTRUE"):("\pFALSE") );
  94.  
  95. /*******************  TELL THEM HOW TO QUIT  ******************/
  96.             strcpy ( (char *) utility_string, "\p(Click the mouse to continue.)" );
  97.             r = w->portRect;
  98.             MoveTo ( r.left + ( r.right - r.left - StringWidth ( utility_string ) ) / 2, r.bottom - 6 );
  99.             DrawString ( utility_string );
  100.             
  101. /*******************  WAIT FOR BUTTON CLICK, THEN EXIT  ******************/            
  102.             while ( Button () );
  103.             while ( ! Button () );
  104.             while ( Button () );
  105.             
  106.             HideWindow ( w );
  107.             DisposeWindow ( w );
  108.         }
  109.     
  110.     SetPort ( hostPort );
  111. /**************************************************************/
  112. /***** END OF EXAMPLE CODE ************************************/
  113. /**************************************************************/
  114.     
  115.     HSetState ( ResHandle, HState );        /*    This is mandatory!                    */
  116. }
  117.